# -*- coding: utf-8 -*-
from PyQt4 import QtCore , QtGui , uic
from lib.papyDB import papyDB
from lib.papyDBTable import * 
from lib.itemModel import toolDataHandler, treeItem, PSSdata
from lib.folderMaker import papyfolder
from lib import globalVar as GV
from types import *
import os

#dumpModel = 'sfasdf \n ifajlefi'
#print dumpModel
#userID=4
#fID=1
##JOB_ASSEMBLE.register( assmTableModel=dumpModel , userID=4 , fID=1 )
#
#
#query = 'insert into JOB_ASSEMBLE(assmTableModel,userID,fID) values("%s","%s","%s")' % (dumpModel , userID, fID)
#
#print query
#
##uery = 'select userID from USER_INFO where userLogInname ="%s"' % os.environ['username']


pickleData = "(ilib.itemModel \nappInfo \np0 \n(dp1 \nS'pos' \np2 \n(lp3 \nI0 \naI0 \nasS'appData' \np4 \n(dp5 \nS'prjIndex' \np6 \nI0 \nsS'shotIndex' \np7 \nI0 \nsS'seqIndex' \np8 \nI1 \nssS'size' \np9 \n(lp10 \nI682 \naI551 \nasb."


if TOOLS_INFO.getFetch( "select count(*) from TOOLS_INFO where userID='%s' and toolName='%s'" % (4,'shotAssembler') )[0][0]:
    TOOLS_INFO.update( 'data' , str( pickleData ) , userID = 4, toolName = 'shotAssembler' )
    print "AAAA"
else :                        
#    TOOLS_INFO.register( self.userID, self.toolName , str(pickleData) )
    query = 'insert into TOOLS_INFO(userID,toolName,data) values("%s","%s","%s")' % (4 , 'shotAssembler', pickleData)
    papyDB.query(query)
    print "BBBBB"




#query = 'insert into TOOLS_INFO(userID,toolName,data) values("%s","%s","%s")' % (4 , 'shotAssembler', pickleData)
#papyDB.query(query)


#print TOOLS_INFO.getFetch( "select count(*) from TOOLS_INFO where userID='%s' and toolName='%s'" % (4,'shotAssembler') )[0][0]